home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lantools / blueprnt / misc.mod < prev    next >
Text File  |  1989-11-28  |  5KB  |  223 lines

  1. ;*************************************************************
  2. ;* Miscellaneous Subroutine Module                (MISC.MOD) *
  3. ;* by Craig Chaiken                                          *
  4. ;* November 28, 1989                                         *
  5. ;*                                                           *
  6. ;* Function: General Purpose Subroutines and Macros          *
  7. ;*************************************************************
  8.  
  9. ticks_low       dw      ?
  10. ticks_high      dw      ?
  11.  
  12. cmz    macro        ;*** Complement Z Flag ***
  13.     lahf
  14.     xor    ah,64
  15.     sahf
  16.     endm
  17.  
  18. stz    macro        ;*** Set Carry Flag ***
  19.     cmp    al,al
  20.     endm
  21.  
  22. clz    macro        ;*** Clear Carry Flag ***
  23.     lahf
  24.     and    ah,255-64
  25.     sahf
  26.     endm
  27.  
  28. pushall macro           ;*** Save All Registers ***
  29.         pushf
  30.         push    es
  31.         push    ds
  32.         push    bp
  33.         push    di
  34.         push    si
  35.         push    dx
  36.         push    cx
  37.         push    bx
  38.         push    ax
  39.         endm
  40.  
  41. popall  macro           ;*** Restore All Registers ***
  42.         pop     ax
  43.         pop     bx
  44.         pop     cx
  45.         pop     dx
  46.         pop     si
  47.         pop     di
  48.         pop     bp
  49.         pop     ds
  50.         pop     es
  51.         popf
  52.         endm
  53.  
  54. get_opt proc    near    ;*** CX = Next Integer after DS:SI of form /nnnnn ***
  55.         xor     cx,cx
  56.         call    wslash
  57.         cmp     al,1fh
  58.         jb      get_o1
  59.         call    get_dec
  60. get_o1: ret
  61. get_opt endp
  62.  
  63. get_dec proc    near    ;*** CX = ASCII Decimal Number at DS:SI ***
  64.         push    ax      ;***  or ASCII HEX Preceeded by '$'     ***
  65.         pushf
  66.         xor     cx,cx
  67.         xor     ah,ah
  68.         cmp     byte ptr [si],'$'
  69.         jz      get_hex
  70. get_d1: mov     al,[si]
  71.         cmp     al,'0'
  72.         jb      get_d2
  73.         cmp     al,'9'
  74.         ja      get_d2
  75.         sub     al,30h
  76.         call    cx10
  77.         add     cx,ax
  78.         inc     si
  79.         jmp     get_d1
  80. get_d2: popf
  81.         pop     ax
  82.         ret
  83.  
  84. get_hex:
  85.         inc     si
  86. get_d3: mov     al,[si]
  87.         cmp     al,'0'
  88.         jc      get_d2
  89.         cmp     al,'9'+1
  90.         jc      get_d4
  91.         and     al,255-32       ;convert to uppercase
  92.         cmp     al,'A'
  93.         jc      get_d2
  94.         cmp     al,'F'
  95.         ja      get_d2
  96.         sub     al,7
  97. get_d4: sub     al,'0'
  98.         add     cx,cx
  99.         add     cx,cx
  100.         add     cx,cx
  101.         add     cx,cx
  102.         add     cx,ax
  103.         inc     si
  104.         jmp     get_d3
  105. get_dec endp
  106.  
  107. get_ticks       proc    near    ;DX=MSW of ticks since boot time
  108.         push    es              ;CX=LSW of ticks since boot time
  109.         push    di
  110.         push    ax
  111.     mov    ah,1
  112.     int    16h
  113.         mov     ax,40h
  114.         mov     es,ax
  115.         mov     di,6ch
  116.         mov     cx,es:[di]
  117.         mov     dx,es:[di+2]
  118.         pop     ax
  119.         pop     di
  120.         pop     es
  121.         ret
  122. get_ticks       endp
  123.  
  124. wait_a_sec      proc    near    ;pause approximately one second
  125.         push    cx
  126.         push    dx
  127.         call    get_ticks
  128.         mov     cs:ticks_low,cx
  129.         mov     cs:ticks_high,dx
  130. wait_1: call    get_ticks
  131.         sub     cx,cs:ticks_low
  132.         sbb     dx,cs:ticks_high
  133.         cmp     cx,19
  134.         jc      wait_1
  135.         pop     dx
  136.         pop     cx
  137.         ret
  138. wait_a_sec      endp
  139.  
  140. cx10    proc    near    ;*** Multiply CX by 10 ***
  141.         push    bx
  142.         add     cx,cx
  143.         mov     bx,cx
  144.         add     cx,cx
  145.         add     cx,cx
  146.         add     cx,bx
  147.         pop     bx
  148.         ret
  149. cx10    endp
  150.  
  151. wslash  proc    near            ;al=first character after slash
  152.         mov     al,[si]         ;   or control character if no slash
  153.         inc     si
  154.         cmp     al,'/'
  155.         jz      wslas1
  156.         cmp     al,1fh
  157.         ja      wslash
  158.         ret
  159. wslas1: mov     al,[si]
  160.         ret
  161. wslash  endp
  162.  
  163. sitodi  proc    near    ;*** Move CX bytes from DS:SI to DS:DI ***
  164.         pushf
  165.         push    es
  166.         push    ds
  167.         pop     es
  168.         cld
  169.         shr     cx,1
  170.         rep     movsw
  171.         rcl     cx,1
  172.         rep     movsb
  173.         pop     es
  174.         popf
  175.         ret
  176. sitodi  endp
  177.  
  178. essitodi        proc    near    ;*** Move CX bytes from ES:SI to DS:DI ***
  179.         pushf
  180.         push    es
  181.         push    ds
  182.         push    es      ;swap ES and DS
  183.         push    ds
  184.         pop     es
  185.         pop     ds
  186.         cld
  187.         shr     cx,1
  188.         rep     movsw
  189.         rcl     cx,1
  190.         rep     movsb
  191.         pop     ds
  192.         pop     es
  193.         popf
  194.         ret
  195. essitodi        endp
  196.  
  197. sitoesdi        proc    near    ;*** Move CX bytes from DS:SI to ES:DI ***
  198.         pushf
  199.         cld
  200.         shr     cx,1
  201.         rep     movsw
  202.         rcl     cx,1
  203.         rep     movsb
  204.         popf
  205.         ret
  206. sitoesdi        endp
  207.  
  208. uppercase       proc    near    ;*** Convert Byte in AL to Uppercase ***
  209.         cmp     al,'a'
  210.         jb      upper1
  211.         cmp     al,'z'
  212.         ja      upper1
  213.         and     al,255-32
  214. upper1: ret
  215. uppercase       endp
  216.  
  217. ;*************************************************************
  218. ;* End of Miscellaneous Subroutine Module                    *
  219. ;*************************************************************
  220.  
  221.  
  222.  
  223.